package com.jnevision.leave.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jnevision.common.CommonQuery;
import com.jnevision.leave.mapper.LeaveMapper;
import com.jnevision.leave.model.Leave;
import com.jnevision.leave.model.LeaveVO;

import io.lettuce.core.dynamic.annotation.Param;

/**
 * <p>
 * 请假 服务实现类
 * </p>
 *
 * @author gavin
 * @since 2019-07-13
 */
@Service
public class LeaveServiceImpl extends ServiceImpl<LeaveMapper, Leave> {
    public List<LeaveVO> getApprove(String userId) {
        return this.baseMapper.getApprove(userId);
    }

    public LeaveVO getApproveDetail(String leaveRecordId) {
        return this.baseMapper.getApproveDetail(leaveRecordId);
    }

    public R<IPage<LeaveVO>> page(Page<LeaveVO> page, CommonQuery commonQuery, Integer result) {
        return R.ok(this.baseMapper.page(page, commonQuery, result));
    }

    public IPage<LeaveVO> myLeaves(Page<LeaveVO> page, @Param("userId") String userId) {
        return this.baseMapper.myLeaves(page, userId);
    }

    public List<LeaveVO> leaveFinished(String userId, String start, String end) {
        return this.baseMapper.leaveFinished(userId, start, end);
    }

    public String myLeaveDuration(CommonQuery query) {
        return this.baseMapper.myLeaveDuration(query);
    }

    public String hunjia(CommonQuery query) {
        return this.baseMapper.hunjia(query);
    }

    public String sangjia(CommonQuery query) {
        return this.baseMapper.sangjia(query);
    }
}
